package plus.easydo.starter.lock.properties;

import org.springframework.boot.autoconfigure.data.redis.RedisProperties;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author yuzhanfeng
 */
@ConfigurationProperties(
        prefix = "spring.redis"
)
@EnableConfigurationProperties(RedisProperties.class)
public class RedissonProperties {

    @Resource
    private RedisProperties redisProperties;

    /**
     * 池配置
     */
    private Redisson redisson;

    public String getHost() {
        return redisProperties.getHost();
    }

    public int getPort() {
        return redisProperties.getPort();
    }

    public Redisson getRedisson() {
        return redisson;
    }

    public void setRedisson(Redisson redisson) {
        this.redisson = redisson;
    }

    public static class Redisson {


        /**
         * 如果池连接没有用于超时时间，
         * 并且当前连接数量大于最小空闲连接池大小，
         * 那么它将关闭并从池中删除。
         * 值以毫秒为单位。
         */
        private int idleConnectionTimeout = 10000;

        /**
         * ping连接时间间隔
         */
        private int pingConnectionInterval;

        /**
         * Redis服务器响应超时。Redis命令发送成功后开始倒计时。
         * 值以毫秒为单位。
         */
        private int timeout = 3000;

        /**
         * Redis鉴权密码。如果不需要应该为空。
         */
        private String password;

        /**
         * 每个Redis连接的订阅量限制
         */
        private int subscriptionsPerConnection = 5;

        /**
         * 启用ssl端点识别
         */
        private boolean sslEnableEndpointIdentification = true;

        /**
         * ssl提供程序 JDK OPENSSL
         */
        private String sslProvider = "JDK";

        /**
         * ssl信任库
         */
        private String sslTruststore;

        /**
         * ssl信任库密码
         */
        private String sslTruststorePassword;

        /**
         * ssl密钥存储库
         */
        private String sslKeystore;

        /**
         * ssl密钥存储库密码
         */
        private String sslKeystorePassword;

        /**
         * 保持活跃
         */
        private boolean keepAlive;

        /**
         * tcp没有延迟
         */
        private boolean tcpNoDelay;

        /**
         * 连接Redis服务超时时间。
         * 值以毫秒为单位。
         */
        private int connectTimeout = 10000;

        /**
         * 最小空闲Redis连接数
         */
        private int connectionMinimumIdleSize = 32;

        /**
         * Redis连接最大池大小
         */
        private int connectionPoolSize = 64;

        /**
         * 客户端连接名称
         */
        private String clientName;

        /**
         * 哨兵模式主节点名称
         */
        private String masterName = "master";

        /**
         * Redis连接的数据库索引
         */
        private int database = 0;

        /**
         * 集群节点
         */
        private List<String> nodes;
        /**
         * 集群状态扫描间隔时间，单位是毫秒
         */
        private int scanInterval = 5000;
        /**
         * 默认值： SLAVE（只在从服务节点里读取）设置读取操作选择节点的模式。 可用值为： SLAVE - 只在从服务节点里读取。
         * MASTER - 只在主服务节点里读取。 MASTER_SLAVE - 在主从服务节点里都可以读取
         */
        private String readMode = "SLAVE";
        /**
         * （从节点连接池大小） 默认值：64
         */
        private int slaveConnectionPoolSize = 64;
        /**
         * 主节点连接池大小）默认值：64
         */
        private int masterConnectionPoolSize = 64;
        /**
         * （命令失败重试次数） 默认值：3
         */
        private int retryAttempts = 3;
        /**
         * 命令重试发送时间间隔，单位：毫秒 默认值：1500
         */
        private int retryInterval = 1500;
        /**
         * 执行失败最大次数默认值：3
         */
        private int failedAttempts = 3;
        /**
         * 从连接最小空闲大小
         */
        private int slaveConnectionMinimumIdleSize = 32;
        /**
         * 失败重新连接时间
         */
        private int failedSlaveReconnectionInterval = 3000;
        /**
         * 失败的从机检查间隔
         */
        private int failedSlaveCheckInterval = 180000;
        /**
         * Redis master节点最小空闲连接量
         */
        private int masterConnectionMinimumIdleSize = 32;
        /**
         * 订阅模式
         */
        private String subscriptionMode = "MASTER";
        /**
         * Redis slave节点最小空闲订阅(pubsub)连接数
         */
        private int subscriptionConnectionMinimumIdleSize = 1;
        /**
         * Redis slave节点最大订阅(pubsub)连接池大小
         */
        private int subscriptionConnectionPoolSize = 50;
        /**
         * dns监视时间间隔
         */
        private long dnsMonitoringInterval = 5000;

        public String getClientName() {
            return clientName;
        }

        public void setClientName(String clientName) {
            this.clientName = clientName;
        }

        public int getTimeout() {
            return timeout;
        }

        public void setTimeout(int timeout) {
            this.timeout = timeout;
        }

        public String getMasterName() {
            return masterName;
        }

        public void setMasterName(String masterName) {
            this.masterName = masterName;
        }

        public int getDatabase() {
            return database;
        }

        public void setDatabase(int database) {
            this.database = database;
        }

        public int getConnectionMinimumIdleSize() {
            return connectionMinimumIdleSize;
        }

        public void setConnectionMinimumIdleSize(int connectionMinimumIdleSize) {
            this.connectionMinimumIdleSize = connectionMinimumIdleSize;
        }

        public int getConnectionPoolSize() {
            return connectionPoolSize;
        }

        public void setConnectionPoolSize(int connectionPoolSize) {
            this.connectionPoolSize = connectionPoolSize;
        }

        public int getIdleConnectionTimeout() {
            return idleConnectionTimeout;
        }

        public void setIdleConnectionTimeout(int idleConnectionTimeout) {
            this.idleConnectionTimeout = idleConnectionTimeout;
        }


        public int getPingConnectionInterval() {
            return pingConnectionInterval;
        }

        public void setPingConnectionInterval(int pingConnectionInterval) {
            this.pingConnectionInterval = pingConnectionInterval;
        }

        public String getPassword() {
            return password;
        }

        public void setPassword(String password) {
            this.password = password;
        }

        public int getSubscriptionsPerConnection() {
            return subscriptionsPerConnection;
        }

        public void setSubscriptionsPerConnection(int subscriptionsPerConnection) {
            this.subscriptionsPerConnection = subscriptionsPerConnection;
        }

        public boolean isSslEnableEndpointIdentification() {
            return sslEnableEndpointIdentification;
        }

        public void setSslEnableEndpointIdentification(boolean sslEnableEndpointIdentification) {
            this.sslEnableEndpointIdentification = sslEnableEndpointIdentification;
        }

        public String getSslProvider() {
            return sslProvider;
        }

        public void setSslProvider(String sslProvider) {
            this.sslProvider = sslProvider;
        }

        public String getSslTruststore() {
            return sslTruststore;
        }

        public void setSslTruststore(String sslTruststore) {
            this.sslTruststore = sslTruststore;
        }

        public String getSslTruststorePassword() {
            return sslTruststorePassword;
        }

        public void setSslTruststorePassword(String sslTruststorePassword) {
            this.sslTruststorePassword = sslTruststorePassword;
        }

        public String getSslKeystore() {
            return sslKeystore;
        }

        public void setSslKeystore(String sslKeystore) {
            this.sslKeystore = sslKeystore;
        }

        public String getSslKeystorePassword() {
            return sslKeystorePassword;
        }

        public void setSslKeystorePassword(String sslKeystorePassword) {
            this.sslKeystorePassword = sslKeystorePassword;
        }

        public boolean isKeepAlive() {
            return keepAlive;
        }

        public void setKeepAlive(boolean keepAlive) {
            this.keepAlive = keepAlive;
        }

        public boolean isTcpNoDelay() {
            return tcpNoDelay;
        }

        public void setTcpNoDelay(boolean tcpNoDelay) {
            this.tcpNoDelay = tcpNoDelay;
        }

        public int getConnectTimeout() {
            return connectTimeout;
        }

        public void setConnectTimeout(int connectTimeout) {
            this.connectTimeout = connectTimeout;
        }

        public List<String> getNodes() {
            return nodes;
        }

        public void setNodes(List<String> nodes) {
            this.nodes = nodes;
        }

        public int getScanInterval() {
            return scanInterval;
        }

        public void setScanInterval(int scanInterval) {
            this.scanInterval = scanInterval;
        }

        public String getReadMode() {
            return readMode;
        }

        public void setReadMode(String readMode) {
            this.readMode = readMode;
        }

        public int getSlaveConnectionPoolSize() {
            return slaveConnectionPoolSize;
        }

        public void setSlaveConnectionPoolSize(int slaveConnectionPoolSize) {
            this.slaveConnectionPoolSize = slaveConnectionPoolSize;
        }

        public int getMasterConnectionPoolSize() {
            return masterConnectionPoolSize;
        }

        public void setMasterConnectionPoolSize(int masterConnectionPoolSize) {
            this.masterConnectionPoolSize = masterConnectionPoolSize;
        }

        public int getRetryAttempts() {
            return retryAttempts;
        }

        public void setRetryAttempts(int retryAttempts) {
            this.retryAttempts = retryAttempts;
        }

        public int getRetryInterval() {
            return retryInterval;
        }

        public void setRetryInterval(int retryInterval) {
            this.retryInterval = retryInterval;
        }

        public int getFailedAttempts() {
            return failedAttempts;
        }

        public void setFailedAttempts(int failedAttempts) {
            this.failedAttempts = failedAttempts;
        }

        public int getSlaveConnectionMinimumIdleSize() {
            return slaveConnectionMinimumIdleSize;
        }

        public void setSlaveConnectionMinimumIdleSize(int slaveConnectionMinimumIdleSize) {
            this.slaveConnectionMinimumIdleSize = slaveConnectionMinimumIdleSize;
        }

        public int getFailedSlaveReconnectionInterval() {
            return failedSlaveReconnectionInterval;
        }

        public void setFailedSlaveReconnectionInterval(int failedSlaveReconnectionInterval) {
            this.failedSlaveReconnectionInterval = failedSlaveReconnectionInterval;
        }

        public int getFailedSlaveCheckInterval() {
            return failedSlaveCheckInterval;
        }

        public void setFailedSlaveCheckInterval(int failedSlaveCheckInterval) {
            this.failedSlaveCheckInterval = failedSlaveCheckInterval;
        }

        public int getMasterConnectionMinimumIdleSize() {
            return masterConnectionMinimumIdleSize;
        }

        public void setMasterConnectionMinimumIdleSize(int masterConnectionMinimumIdleSize) {
            this.masterConnectionMinimumIdleSize = masterConnectionMinimumIdleSize;
        }

        public String getSubscriptionMode() {
            return subscriptionMode;
        }

        public void setSubscriptionMode(String subscriptionMode) {
            this.subscriptionMode = subscriptionMode;
        }

        public int getSubscriptionConnectionMinimumIdleSize() {
            return subscriptionConnectionMinimumIdleSize;
        }

        public void setSubscriptionConnectionMinimumIdleSize(int subscriptionConnectionMinimumIdleSize) {
            this.subscriptionConnectionMinimumIdleSize = subscriptionConnectionMinimumIdleSize;
        }

        public int getSubscriptionConnectionPoolSize() {
            return subscriptionConnectionPoolSize;
        }

        public void setSubscriptionConnectionPoolSize(int subscriptionConnectionPoolSize) {
            this.subscriptionConnectionPoolSize = subscriptionConnectionPoolSize;
        }

        public long getDnsMonitoringInterval() {
            return dnsMonitoringInterval;
        }

        public void setDnsMonitoringInterval(long dnsMonitoringInterval) {
            this.dnsMonitoringInterval = dnsMonitoringInterval;
        }

    }


}
